package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2021/12/1 0:44
 * @description：https://leetcode-cn.com/problems/consecutive-characters/
 */
public class 连续字符 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.maxPower("abbcccddddeeeeedcba"));
    }

    class Solution {
        public int maxPower(String s) {
            char[] chars = s.toCharArray();
            int max = 1;
            int i = 0, j = 1;
            int len = chars.length;
            while (i < len) {
                while (j < len && chars[i] == chars[j]) j++;
                max = Math.max(max, j - i);
                i = j;
                j++;
            }
            return max;
        }
    }

}
